import { createApp, h } from 'vue';

import App from './App.vue';
// 导入路由
// createWebHashHistory  Hash
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';

import Home from './views/Home.vue';
import Shop from './views/Shop.vue';
import NotFound from './views/NotFound.vue';

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/home',
      name: 'home',
      component: Home,
      beforeEnter(to, from, next) {
        console.log('beforeEnter');
        next();
      }
    }, {
      path: '/shop/:id',
      name: 'shop',
      component: Shop
    }, {
      path: '/:str(.*)',
      component: NotFound
    }
  ]
});

router.beforeEach((to, from, next) => {
  console.log('beforeEach');
  next();
});

router.beforeResolve((to, from, next) => {
  console.log('beforeResolve');
  next();
});

router.afterEach((to, from) => {
  console.log('afterEach');
});


const app = createApp(App);

app.use(router);

app.mount('#app');
